package com.jeehentor.ai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeehentor.ai.entity.AiChatMessage;
import com.jeehentor.ai.mapper.AiChatMessageMapper;
import com.jeehentor.ai.service.AiChatMessageService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.baomidou.mybatisplus.extension.toolkit.Db.list;

/**
 * @Description : TODO
 * @Author : wzd
 * @Date : 2025/4/18 9:37
 * @Version : 1.0
 **/
@Service
public class AiChatMessageServiceImpl extends ServiceImpl<AiChatMessageMapper, AiChatMessage>
        implements AiChatMessageService {

    @Override
    public List<AiChatMessage> getBySessionId(String sessionId) {
        LambdaQueryWrapper<AiChatMessage> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(AiChatMessage::getSessionId, sessionId)
                .orderByAsc(AiChatMessage::getCreateTime);
        return list(wrapper);
    }
}